#!/usr/bin/env python
import numpy as np
import scipy.linalg as la

print ('inner product')

A = [
		[1, 3],
		[2, 4]
	]
B = [
		[2, 1],
		[3, 4]
	]

_A = np.mat('[1 3 ; 2 4]')
_B = np.mat('[2 1 ; 3 4]')


print (_A * _B)
#C = [[0 for x in range (2)] for x in range(2) ]

C = np.zeros((2,2), dtype=int)
print ('multiply by inner')
# A row
for i in range( len(A)) :
	# A col
	for j in range(len(A[0])) :
		for k in range(len(B)) :
			C[i][j] += A[i][k] * B[k][j]
			
		
print (C)

C = np.zeros((2,2), dtype=int)

print ('multiply by outer')
# B row 
for i in range( len(A)) :
	# A col
	for j in range(len(A[0])) :
		#A row 
		for k in range(len(B)) :
			#print (str(list([k,i])) + ',' + str(list([i,j])))
			C[k][j] += A[k][i] * B[i][j]

print (C)

C = np.zeros((2,2), dtype=int)

print ('multiply by row row')
# B row 
for i in range( len(A)) :
	# A col
	for j in range(len(A[0])) :
		#A row 
		for k in range(len(B)) :
			C[i][k] += A[i][j] * B[j][k]

print (C)

C = np.zeros((2,2), dtype=int)

print ('multiply col by col')
# A row 
for i in range( len(A)) :
	# A col
	for j in range(len(A[0])) :
		#B col
		for k in range(len(B)) :
			C[k][j] += A[k][i] * B[i][j]
print (C)